<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <tr>
        <th>id</th>
        <th>姓名</th>
        <th>工作</th>
        <th>年龄</th>
        <th>操作</th>
    </tr>
    <tr v-for="emp in arr">
        <th>{{emp.id}}</th>
        <th><a :href="'/update.html?id='+emp.id">{{emp.name}}</a></th>
        <th>{{emp.job}}</th>
        <th>{{emp.age}}</th>
        <th><a href="#" @click="del(emp.id)">删除</a></th>
    </tr>
</table>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v=new Vue({
        el:"table",
        data:{
            arr:[]
        },
        created:function () {
            axios.get("/select").then(function (response) {
                v.arr=response.data;
            })
        },
        methods:{
            del:function (id) {
                axios.get("/delete?id="+id).then(function (response) {
                    if (confirm("确定删除吗?")){
                        alert("删除成功")
                        location.reload();
                    }
                })
            }
        }
    })
</script>
</body>
</html>